package com.xbj.voa.exception;

import lombok.Data;

/**
 * @author: 木火
 * @create: 2024-01-02
 * @description:自定义异常类
 *  为什么继承RuntimException,而不是Exception.
 *      因为Exception必须手动显示处理,要么上抛,要么捕获.RuntimeException既可以显示处理,也可以被虚拟机隐式处理
 **/
@Data
public class VoaException extends RuntimeException{
    /**
     *
     */
    private String msg;
    private int code = 500;

    public VoaException(String msg){
        super(msg);
        this.msg = msg;
    }
    public VoaException(String msg, Throwable e){
        super(msg,e);
        this.msg = msg;
    }
    public VoaException(String msg, int code){
        super(msg);
        this.msg = msg;
        this.code = code;
    }
    public VoaException(String msg, int code, Throwable e){
        super(msg,e);
        this.msg = msg;
        this.code = code;
    }
}
